<!--
 * @Author: liuhanzhuang
 * @Date: 2023-01-11 11:05:57
 * @Description: 文件描述
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        box-sizing: border-box;
      }

      :root {
        --loading-grey: rgb(247, 244, 244);
      }

      body {
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        height: 100vh;
      }

      .card {
        display: flex;
        flex-direction: column;
        width: 250px;
        height: 300px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        border-radius: 5px;
        padding: 10px;
      }

      .card .img-con {
        flex: 3;
      }

      .card .img-con img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }

      .card .content {
        flex: 2;
        overflow: hidden;
        font-size: 15px;
        line-height: 15px;
        margin-top: -5px;
      }

      .loading .title {
        height: 30px;
      }

      .loading .text {
        height: 50px;
      }

      .loading .img-con,
      .loading .title,
      .loading .text {
        /* background-color: var(--loading-grey); */
        background: linear-gradient(100deg, rgba(0, 0, 0, 0) 40%, rgba(255, 255, 255, 0.6) 50%, rgba(0, 0, 0, 0) 60%)
          var(--loading-grey);
        background-size: 200% 100%;
        animation: 1s loading linear infinite;
      }

      @keyframes loading {
        0% {
          background-position-x: 180%;
        }

        100% {
          background-position-x: -20%;
        }
      }
    </style>
  </head>

  <body>
    <div class="card" id="card1">
      <div class="img-con">
        <img alt="" />
      </div>
      <div class="content">
        <h4 class="title"></h4>
        <p class="text"></p>
      </div>
    </div>
    <div class="card loading">
      <div class="img-con"></div>
      <div class="content">
        <h4 class="title"></h4>
        <p class="text"></p>
      </div>
    </div>
  </body>
  <script>
    let cardEl = document.querySelector("#card1")
    cardEl.classList.add("loading")
    setTimeout(() => {
      cardEl.classList.remove("loading")
      cardEl.querySelector("img").src = "https://assets.codepen.io/2002878/wake-up-and-code.jpg"
      cardEl.querySelector(".title").innerText = "CodingStartup"
      cardEl.querySelector(".text").innerText =
        "Lorem ipsum dolor, sit amet consectetur adipisicing elit. Ex quasi enim facere commodi omnis..."
    }, 4000)
  </script>
</html>
